
case class pro(name:String,age:Int)

object HelloScala {
  def main(args: Array[String]): Unit = {

    val pro1=new pro("zhangsan",18)
    val pro2=new pro("lisi",22)

    val prolist=List(pro1,pro2)

    prolist.foreach(x=>{
      x match {
        case pro("zhangsan",18) => println("I am zhangsan")
        case _ => println("no match")
      }
    })

    //    模式匹配  类似于 java
//    def matchTest(x: Any) = {
//      x match {
//        case pro("zhangsan",18) => println("I am zhangsan")
//        case x: Int => println("type is Int")
//        case 1.1 => println("number is 1.1")
//        case 2.2 => println("number is 2.2")
//        case x: String => println("type is string")
//        case _ => println("no match")
//      }
//
//    }
//
//    matchTest("hhaha")

  }

}
